package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectPageVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description NursingProjectController
 * @Author xzy
 * @Date 2025-05-08  11:35
 */
@RestController
@RequestMapping("nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController extends BaseController{

    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation(value = "分页查询护理项目")
    public ResponseResult<PageResponse<NursingProjectVo>> pageNursingProject(
            @ApiParam(value = "护理项目分页请求体,包括项目名和状态")NursingProjectPageVo nursingProjectPageVo
            ){
        PageResponse<NursingProjectVo> PageResponse = nursingProjectService.pageNursingProjects(nursingProjectPageVo);
        return success(PageResponse);
    }

    @PostMapping
    @ApiOperation(value = "添加护理项目")
    public ResponseResult addNursingProject(@ApiParam(value = "护理项目VO")
                                                @RequestBody NursingProjectVo nursingProjectVo){
        nursingProjectService.addNursingProject(nursingProjectVo);
        return success();
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID查询护理项目")
    public ResponseResult<NursingProjectVo> findNursingProjectById(
            @ApiParam(value = "护理项目ID",required = true)  @PathVariable Long id){
        NursingProjectVo nursingProjectVo = nursingProjectService.getNursingProjectById(id);
        return success(nursingProjectVo);
    }

    @PutMapping
    @ApiOperation(value = "修改护理项目")
    public ResponseResult modifyNursingProject(
            @ApiParam(value = "护理项目VO")@RequestBody NursingProjectVo nursingProjectVo){
        nursingProjectService.modifyNursingProject(nursingProjectVo);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "根据ID删除护理项目")
    public ResponseResult removeNursingProject(
            @ApiParam(value = "护理项目ID",required = true) @PathVariable Long id
    ){
        nursingProjectService.removeNursingProject(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "启用/禁用护理项目")
    public ResponseResult enableOrDisable(
            @ApiParam(value = "护理项目ID",required = true) @PathVariable Long id,
            @ApiParam(value = "护理项目状态",required = true)  @PathVariable Integer status
    ){
        nursingProjectService.enableOrDisable(id,status);
        return success();
    }

}
